<template>
	<el-form :model="formData" ref="formRef" :rules="formRules" label-width="8rem">
		<el-row type="flex" :gutter="10">
			<!-- <el-col :span="12">
				<el-form-item label="类型" prop="type">
					<el-select v-model="formData.type" placeholder="请选择">
						<el-option v-for="item in Companynature" :key="item.value" :label="item.label"
							:value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
			</el-col> -->
			<el-col :span="16">
				<el-form-item label="入库分类标签名" prop="name">
					<el-input v-model="formData.name"></el-input>
				</el-form-item>
			</el-col>
		</el-row>
		<el-row type="flex" justify="center">
			<el-button type="primary" icon="el-icon-check" @click="onConfirm">确认</el-button>
			<el-button type="default" icon="el-icon-close" @click="onCancel">取消</el-button>
		</el-row>
	</el-form>
</template>

<script>
	export default {
		name: "classify-add",
		props: {
			formData: {
				type: Object,
				default: () => {}
			},
		},
		data() {
			return {
				Companynature: [{value: 1,label: '客户等级'}, {value: 2,label: '客户来源'}, {value: 3,label: '客户行业'},
				{value: 4,label: '客户类型'}], //1客户等级2客户来源3客户行业4客户类型
				formRules: {
					name: [{
						required: true,
						message: '请输入',
						trigger: 'blur'
					}, ],
					// type: [{
					// 	required: true,
					// 	message: '请选择',
					// 	trigger: 'change'
					// }],
					// source_id: [{
					// 	required: true,
					// 	message: '请选择',
					// 	trigger: 'change'
					// }],
				}
			};
		},
		methods: {
			onConfirm() {
				this.$refs.formRef.validate((valid) => {
					if (valid) {
						// alert('submit!');
						this.$emit("search", this.formData);
						this.$parent.$emit("update:visible", false);
						this.$refs.formRef.resetFields()
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			onCancel() {
				this.$parent.$emit("update:visible", false);
				this.$refs.formRef.resetFields();
			}
		}
	};
</script>
